<template>
  <input type="text" :value="value" @input="handleInput" />
</template>

<script>
export default {
  name: 'ElInput',
  props: {
    value: {
      type: String
    }
  },
  methods: {
    handleInput(e) {
      this.$emit('input', e.target.value)

      let parent = this.$parent
      while (parent) {
        const name = parent.$options.name
        if (name === 'ElFormItem') {
          break
        } else {
          parent = parent.$parent
        }
      }
      if (parent) {
        parent.$emit('validate', e.target.value)
      }
    }
  }
}
</script>

<style lang="scss" scoped></style>
